#include "head.h"


int init_socket(int *socket_fd, char *ip, char *port){
    printf("port:%s,ip:%s",port,ip);
    *socket_fd = socket(AF_INET, SOCK_STREAM, 0);

    struct sockaddr_in sockaddr;

    sockaddr.sin_family = AF_INET;
    sockaddr.sin_port = htonl(atoi(port));
    sockaddr.sin_addr.s_addr = inet_addr(ip);

    int ret = connect(*socket_fd, (struct sockaddr*)&sockaddr, sizeof(sockaddr));

    if (ret == -1){
        error(1,errno,"ret:%d\n",ret);
        return -1;

    }
    return 0;
}
